package com.lightheart.sphr.xiaobinggan.stickynote.ui

import android.view.View
import com.lightheart.sphr.xiaobinggan.R
import com.lightheart.sphr.xiaobinggan.base.BaseActivity
import com.lightheart.sphr.xiaobinggan.module.home.presenter.HomePresenter
import com.pengyeah.tear.PaperLayout.OnTearStateChangeListener
import com.pengyeah.tear.STATE_TEARED
import kotlinx.android.synthetic.main.activity_sticky_note.*

//https://mp.weixin.qq.com/s/Zw_fu4FWGs3mKsvGei8Qdw
class StickyNoteActivity : BaseActivity<HomePresenter>() {

    override fun getLayoutId() = R.layout.activity_sticky_note

    override fun initInjector() {

    }

    override fun initView() {
        paperLayout1.onTearStateChangeListener = object : OnTearStateChangeListener {
            override fun onTearStateChanged(tearState: Int) {
                if (tearState == STATE_TEARED) {
                    paperLayout1.visibility = View.GONE
                }
            }
        }
        paperLayout2.onTearStateChangeListener = object : OnTearStateChangeListener {
            override fun onTearStateChanged(tearState: Int) {
                if (tearState == STATE_TEARED) {
                    paperLayout2.visibility = View.GONE
                }
            }
        }
        paperLayout3.onTearStateChangeListener = object : OnTearStateChangeListener {
            override fun onTearStateChanged(tearState: Int) {
                if (tearState == STATE_TEARED) {
                    paperLayout3.visibility = View.GONE
                }
            }
        }

        btn1.setOnClickListener { paperLayout1.startTearAnim() }

        btn2.setOnClickListener { paperLayout2.startTearAnim() }

        btn3.setOnClickListener { paperLayout3.startTearAnim() }
    }
}